#include<iostream>
using namespace std;

int fibonacci(int n) { 
    if(n<=1){
        return n;
    }
    int* fib = new int[n+1];
    fib[0] = 0;
    fib[1] = 1;

    for(int i = 2;i<=n;i++){
        fib[i] = fib[i-1] + fib[i-2];
        cout << fib[i] << endl;
    }

    int result = fib[n];

    delete[] fib;
    return result;
}

int main() {
    int n = 9;
    int result = fibonacci(n);
    cout << "The " << n << "th Fibonacci number is: " << result << endl;
    return 0;
}